package org.galaxyworld.flycode.model;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.galaxyworld.flycode.config.ModelConfig;
import org.galaxyworld.flycode.utils.NameUtils;

import java.util.List;

@ToString
public class Table {

    @Setter @Getter
    private String catalog;

    @Setter @Getter
    private String schema;

    @Setter @Getter
    private String name;

    @Setter @Getter
    private String comment;

    @Setter @Getter
    private String rows;

    @Setter @Getter
    private List<Field> fields;

    private String className;

    public String getClassName() {
        if (StringUtils.isBlank(className)) {
            className = NameUtils.tableNameToClassName(name, ModelConfig.getPrefix(), ModelConfig.isIncludePrefix());
        }
        return className;
    }

}
